package com.yoda.mall.model.entity.ums;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yoda.common.validator.group.InsertGroup;
import com.yoda.common.validator.group.UpdateForStatus;
import com.yoda.common.validator.group.UpdateGroup;
import com.yoda.common.validator.annotations.ListValue;
import com.yoda.mall.model.entity.BasePojo;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author shawn
 * @date 2022年 12月 15日 21:16
 */
@Data
@TableName("ums_admin")
public class Admin extends BasePojo {
    @NotNull(message = "修改必须指定品牌id",groups = {UpdateGroup.class, UpdateForStatus.class})
    @Null(message = "新增不能指定id",groups = {InsertGroup.class})
    @TableId
    private Long id;
    @NotBlank(message = "用户名不能为空",groups = {InsertGroup.class,UpdateGroup.class})
    private String username;
    @NotBlank(message = "密码不能为空",groups = {InsertGroup.class,UpdateGroup.class})
    private String password;
    @URL(message = "logo必须是一个合法的url地址",groups = {InsertGroup.class,UpdateGroup.class})
    private String icon;
    @Email(message = "邮箱必须为合法的邮箱地址",groups = {InsertGroup.class,UpdateGroup.class})
    @NotNull(message = "邮箱不能为空",groups = {InsertGroup.class,UpdateGroup.class})
    private String email;
    private String nickName;
    private String note;

    @TableField(fill = FieldFill.UPDATE)
    private LocalDateTime loginTime;

    @NotNull(message = "状态不能为空",groups = {InsertGroup.class, UpdateForStatus.class})
    @ListValue(values={0,1},groups = {InsertGroup.class, UpdateForStatus.class})
    private Integer status;
}
